package com.google.smartbinding.framework.swt.demo.view.controller;

import java.util.LinkedList;
import java.util.List;

import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;

import com.google.smartbinding.framework.swt.demo.view.DemoComposite;
import com.google.smartbinding.framework.swt.demo.view.model.DemoCompositeModel;
import com.googlecode.smartbinding.framework.core.DataBindingManagerFactory;

public class DemoCompositeController extends UIController<DemoComposite>{

	private Text textName;
	private Text textWeight;
	private TableViewer tableViewer;
	private Button btnAdd;
	private DemoCompositeModel model;
	List<String> input = new LinkedList<String>();
	
	public DemoCompositeController(DemoComposite view, DemoCompositeModel model) {
		super(view);
		this.model = model;
		bind();
	}

	private void bind() {
		DataBindingManagerFactory.getDatabindingManager().bind(model, view);
	}

	@Override
	protected void execute() {
		textName = view.getTextName();
		textWeight = view.getTextWeight();
		tableViewer = view.getTableViewer();
		btnAdd = view.getBtnAdd();
		
		btnAdd.addSelectionListener(new SelectionListener() {
			
			@Override
			public void widgetSelected(SelectionEvent evt) {
				//add elem to viewer				
			}
			
			@Override
			public void widgetDefaultSelected(SelectionEvent evt) {
				
				//add elem to viewer
			}
		});
	}

	
	
}
